<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

//http://blog.hd/user/dfsdfds
Route::get('user/{id}', function ($id) {
    return 'User '.$id;
})->where('id', '[0-9]+');

//不需要登录的操作
Route::group(['middleware' => ['web']], function () {
    //前台首页
    Route::get('/', 'Home\IndexController@index');
    //列表页
    Route::get('/list/{id}', 'Home\IndexController@clist');

    Route::get('/article/{art_id}', 'Home\IndexController@details');


    Route::any('admin/login', 'Admin\LoginController@login'); //any可匹配get,post,put等; 不需要判断是否登录的中间件

    Route::get('admin/code', 'Admin\LoginController@code'); //登录页面验证码
    //Route::get('admin/getcode', 'Admin\LoginController@getcode'); //验证码查看

    Route::get('admin/logout', 'Admin\LoginController@logout');

});

//创建分组路由 需要登录验证的中间件
Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => ['web','admin.login']], function () {

    Route::get('', 'IndexController@index');
    Route::get('index', 'IndexController@index');

    Route::get('info', 'IndexController@info');

    Route::any('pass', 'IndexController@pass');

    //后台ajax发送post数据更新文章栏目排序
    Route::post('change_order', 'CommonController@change_order');

    //文章分类栏目路由
    Route::resource('category', 'CategoryController');
    //资源路由
    Route::resource('article', 'ArticleController');
    Route::resource('links', 'LinksController');
    Route::resource('navs', 'NavsController');
    Route::resource('config', 'ConfigController');

    //配置项表单提交
    Route::post('save_config', 'ConfigController@save_config');
    Route::get('fiel_save', 'ConfigController@fiel_save');

    //图片上传方法
    Route::any('upload', 'ArticleController@upload');

});

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

Route::group(['middleware' => ['web']], function () {
    //
});
